package com.cloud.clouduser.security.base.code.imagecode;

import java.awt.image.BufferedImage;
import java.time.LocalDateTime;

/**
 * @Aurher: QiaoHang
 * @Description:
 * @Data: 2019/9/25 10:04
 * @Modified By:
 */
public class ImageCode {
    //图片code
    private String code;
    //图片信息
    private BufferedImage BufferedImage;
    //过期时间
    private LocalDateTime localDateTime;

    //该构造函数用于构造一哥ImageCode对象，以及过期时间
    public ImageCode(String code, BufferedImage bufferedImage, int secend) {
        this.code = code;
        BufferedImage = bufferedImage;
        this.localDateTime = LocalDateTime.now().plusSeconds(secend);
    }

    public ImageCode() {

    }
    //是否过期
    public boolean isExpired(){
        return LocalDateTime.now().isAfter(localDateTime);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public java.awt.image.BufferedImage getBufferedImage() {
        return BufferedImage;
    }

    public void setBufferedImage(BufferedImage bufferedImage) {
        BufferedImage = bufferedImage;
    }

    public LocalDateTime getLocalDateTime() {
        return localDateTime;
    }

    public void setLocalDateTime(LocalDateTime localDateTime) {
        this.localDateTime = localDateTime;
    }
}
